@echo off
title ROS2 Robot Controller Server

echo ==========================================
echo     ROS2 Robot Virtual Controller
echo ==========================================
echo.
echo Starting local HTTP server...
echo.

REM Try Python 3 first, then Python 2
python --version >nul 2>&1
if errorlevel 1 (
    echo Python not found, trying python3...
    python3 --version >nul 2>&1
    if errorlevel 1 (
        echo.
        echo ERROR: Python not found in system PATH
        echo Please install Python or double-click index.html directly
        echo.
        echo Download Python: https://www.python.org/downloads/
        echo.
        pause
        exit /b 1
    ) else (
        echo Found Python3, starting server...
        goto :start_python3
    )
) else (
    echo Found Python, starting server...
    goto :start_python
)

:start_python3
echo.
echo Server starting on port 8080...
echo Local URL: http://localhost:8080
echo.
echo Press Ctrl+C to stop server
echo.
start "" "http://localhost:8080"
python3 -m http.server 8080
goto :end

:start_python
echo.
echo Server starting on port 8080...
echo Local URL: http://localhost:8080
echo.
echo Press Ctrl+C to stop server
echo.
start "" "http://localhost:8080"
python -m http.server 8080 2>nul || python -m SimpleHTTPServer 8080
goto :end

:end
echo.
echo Server stopped
pause 